'use strict';

const redis = require('../config/redis');

exports.redis = redis;

const FILE_STATUS = 'file:';
const FILE_STATUS_TTL = 60 * 30;

exports.setFileStatus = function (fid, obj) {
  try {
    let value = JSON.stringify(obj);
    let key = FILE_STATUS + fid;
    return redis.set(key, value, 'EX', FILE_STATUS_TTL);
  // let result = redis.set(key, value, 'EX', FILE_STATUS_TTL)
  // console.log('fileStatus:', result)
  } catch (err) {
    console.error('redis Err:', err);
  }
};

exports.getFileStatus = function (fId) {
  let key = FILE_STATUS + fId;
  return redis.get(key);
};
